package com.lvhr.example.provider;

import com.lvhr.example.common.service.UserService;
import com.lvhr.example.impl.UserServiceImpl;
import com.lvhr.rpc.RpcApplication;
import com.lvhr.rpc.config.RpcConfig;
import com.lvhr.rpc.registry.LocalRegistry;
import com.lvhr.rpc.server.VertxHttpServer;
import com.lvhr.rpc.utils.ConfigUtils;

import java.util.Collections;

/**
 * 简易服务提供者示例
 */
public class ProviderExample {
    public static void main(String[] args) {

        RpcConfig rpc = ConfigUtils.loadConfig(RpcConfig.class,"rpc","", Collections.singletonList("yml"));

        //RPC初始化
        RpcApplication.init(rpc);

        //注册服务
        LocalRegistry.register(UserService.class.getName(), UserServiceImpl.class);

        //启动web服务
        VertxHttpServer httpServer = new VertxHttpServer();
        httpServer.doStart(RpcApplication.getRpcConfig().getServer().getPort());
    }
}
